/* This header unites all the code for the different dungeon segments.
  include this to use segments. */

/*
 * About Segments:
 * A segment has a number of entrances and a number of exits ranging from 1 to MAX_ENTRANCES/MAX_EXITS.
 * Any segment type can be constructed with any number of entrances or exits, most of them
 * simply append or prepend a CORRIDOR-Segment to join or fork the entrances/exits.
 * All exits of segments have a cost and a profit value which try to help in determining the composition
 * and linkage of the segments in the dungeon. Cost estimates how much time and effort the player must
 * spend from the beginning of the dungeon to this exit. Profit estimates how much treasure, experience
 * etc. the player has gathered following the path up to this exit.
 */

#ifndef __SEGMENTS_H_
#define __SEGMENTS_H_

#define MAX_ENTRANCES 4
#define MAX_EXITS 4
#define NUM_SEGTYPES 8

typedef enum {
	ST_CORRIDOR =1, // Unobstrusive pass-through corridor
	ST_MULTIPLEXER, // Joins and splits paths without leaving choice to the player
	ST_SHORTCUT, // Conditional corridor, opens a path once a more advanced path has been visited
	ST_TREASURE, // Free treasure up for grabs
	ST_MONSTER_CHALLENGE, // Fight monsters for treasure & exit
	ST_SWITCH_CHALLENGE, // Flip switches for treasure & exit
	ST_SOKOBAN_CHALLENGE, // Move boxes for treasure & exit
	ST_MULTIPLAYER_CHALLENGE, // Get help from fellow players for treasure or take the exit for free
        ST_GOAL, // The winner is in this room
} SegmentType;

typedef struct segment_t {
	SegmentType type;
	int num_entrances;
	int num_exits;
	struct segment_t* prev [MAX_ENTRANCES];
	struct segment_t* next [MAX_EXITS];
	int cost [MAX_EXITS];
	int profit [MAX_EXITS];
	void (*compute_costs_profits) (struct segment_t* self);
	
	int layouter_data; // Special data field reserved for use by the layouter
	
	union {
		// Reserved for segment type specific data
	};
} Segment;

#endif 
